/**
 * Controll load-info-list.vm
 * Created by zzy on 2016/12/13.
 */
var $ = require('jquery');
require('easyui');
require('easyui/locale/easyui-lang-zh_CN');
require('layout/uiJs');
require("libs/jquery.jqprint-0.3.js");
var $alert = require("libs/alert");
var $confirm = require("libs/confirm");
var isSale = require('libs/user-type').isSale;
var loadInfoId='';
var isAddInroomOrder=false;
var selectedLogisticsPlanId='';
var fixedW = 3;
var fixedV = 6;
var orderStatus={"commit":"已提交","c_collect":"已揽收","c_receive":"已收货",
    "c_ourtoom":"集货出库","p_inroom":"转运入库","p_outroom":"转运出库","o_inroom":"海外入库"};

//物流产品初始化
logisticsInit();
//海外仓初始化
warehouseInit();
//配载单列表初始化
loadInfoGridInit();
//筛选列表
$("#a_search").on("click",function () {
    var d1 = $('#startDt').datebox('getValue');
    var d2 = $('#endDt').datebox('getValue');
    $('#load_info_table').datagrid('load',{
        loadInfoNo:$('#loadInfoNo').val(),
        logisticsId:$('#select_logistics').combobox('getValue'),
        warehouseId:$('#select_warehouse').combobox('getValue'),
        fromCreateDt:d1?$('#startDt').data('utc0'):'',
        toCreateDt:d2?$('#endDt').data('utc0'):''
    });
});
//订舱
$("body").on("click","a[name=bookStore]",function(){
    loadInfoId = $(this).parent().parent().parent().children().eq(0).text();
    $.ajax({
        url:"api/v1/p/mms/loadInfo/bookStore",
        type:'post',
        data:{
            loadInfoId:1*loadInfoId
        },
        dataType:'json',
        success:function (result) {
            if(result.code=="200") {
                $alert("订舱成功!");
                $("#load_info_table").datagrid("reload");
            }else{
                $alert(result.message);
            }
        }
    })
});
//修改
$("body").on("click","a[name=modify]",function(){
    loadInfoId = $(this).parent().parent().parent().children().eq(0).text();
    loadInfoLoad(loadInfoId);
});
//在配载单列表中打印
$("body").on("click","a[name=print]",function(){
    loadInfoId = $(this).parent().parent().parent().children().eq(0).text();
    printInit(loadInfoId);
});
//在配载单列表中生成国内仓发货单
$("body").on("click","a[name=create_ship]",function(){
    loadInfoId = $(this).parent().parent().parent().children().eq(0).text();
    var logisticsChannelPlanId = $(this).parent().parent().parent().children().eq(11).text();
    createInit(loadInfoId,logisticsChannelPlanId);
});
//查看配载单详情
$("body").on("click","a[name=loadNo]",function () {
    loadInfoId = $(this).parent().parent().parent().children().eq(0).text();
    loadInfoLoadReadOnly(loadInfoId);
});
//移除配载单中入库单
$("#load_inroom_order_table").on("click",".remove",function () {
    var thisId = $(this).parent().parent().children().eq(0).text();
    removeLoadInroomOrder(1*thisId,$(this));
});
//继续向已生成配载单中添加入库单
$("#button_add_inroom_order").on("click",function () {
    if(loadInfoId==''){
        $alert("请先生成配载单!");
        return false;
    }else{
        isAddInroomOrder = true;
        $("#dialog_loadinfo table tbody").append("<tr></tr>");
        $('#dialog_loadinfo').modal("hide");
    }
});
//点击关闭按钮时触发
$('#dialog_loadinfo').on('hide.bs.modal', function () {
    if($("#dialog_loadinfo table tbody tr").length<=0){
        $alert("配载单内必须有一条入库单信息!");
        return false;
    }
});
//修改功能中打印按钮
$('#button_print').on('click',function () {
    if($("#dialog_loadinfo table tbody tr").length<=0){
        $alert("配载单内必须有一条入库单信息!");
        return false;
    }else{
        printTool();
    }
});
//详情中打印按钮
$('#button_detail_print').on('click',function () {
    if($("#dialog_loadinfo_readonly table tbody tr").length<=0){
    }else{
        printTool();
    }
});
//dialog关闭时清空数据
$('#dialog_loadinfo').on('hidden.bs.modal', function () {
    $("#div_loadinfo_detail .form-group div").html('');
    $("#load_inroom_order_table tbody").html('');
    if(isAddInroomOrder){
        //隐藏配载单列表模块
        $("#div_loadinfolist_modual").css('display','none');
        //显示添加入库单到配载单模块
        $("#div_modify_modual").css('display','block');
        inroomGridInit();
        //取消全选
        $("#inroom_order_table").datagrid("unselectAll");
        isAddInroomOrder = false;
    }else{
        //显示配载单列表模块
        $("#div_loadinfolist_modual").css('display','block');
        $("#load_info_table").datagrid("reload");
        //取消全选
        $("#load_info_table").datagrid("unselectAll");
        //隐藏添加入库单到配载单模块
        $("#div_modify_modual").css('display','none');
    }
});
//添加入库单到配载单按钮点击事件
$("#button_to_loadinfo").on("click",function () {
    var $selects = $("#inroom_order_table").datagrid("getSelections");
    if($selects.length==0){
        $alert("请选择入库单!");
        return false;
    }
    var arr = [];
    $.each($selects,function (index,obj) {
        var order = {};
        order["orderId"] = obj.orderId;
        arr.push(order);
    });
    if(loadInfoId==''){
        $alert("请先生成配载单!")
        return false;
    }else{
        var obj = {};
        obj["loadInfoId"]=loadInfoId;
        obj["orderIds"]=arr;
    }
    $.ajax({
        url:'api/v1/p/mms/loadInfo/inRoomOrderAdd',
        type:'post',
        contentType: "application/json; charset=utf-8",
        data:JSON.stringify(obj),
        dataType:'json',
        success:function (result) {
            if(result.code == 200){
                loadInfoId = result.data.loadInfoId;
                //读取配载单
                loadInfoLoad(loadInfoId);
            }else{
                $alert(result.message);
            }
        }
    })
});

function printTool(){
    $.ajax({
        url:'api/v1/p/mms/loadInfo/inRoomOrderList',
        type:'post',
        data:{
            loadInfoId:1*loadInfoId,
            page:1,
            rows:100
        },
        dataType:'json',
        success:function (result) {
            if(result.code == 200) {
                var data = result.data.rows;
                var $tbody = $("#load_inroom_order_table_print tbody");
                $tbody.html('');
                var rows='';
                $.each(data,function (index,row) {
                    rows=rows+"<tr><td style='display: none;'>"+row.orderId+"</td><td>"+row.orderNo+
                        "</td><td>"+row.collectWarehouseName+"</td><td>"+row.toWarehouseName+"</td><td>"+
                        row.logisticsName+"</td><td>"+row.logisticsPlanName+"</td>";
                    if(row.cNums==''||row.cNums==null){
                        rows=rows+"<td>"+row.tNums+"</td>";
                    }else{
                        rows=rows+"<td>"+row.cNums+"</td>";
                    }
                    if(row.cWeight==''||row.cWeight==null){
                        rows=rows+"<td>"+Number(row.tWeight).toFixed(fixedW)+"</td>";
                    }else{
                        rows=rows+"<td>"+Number(row.cWeight).toFixed(fixedW)+"</td>";
                    }
                    if(row.cVolumn==''||row.cVolumn==null){
                        rows=rows+"<td>"+Number(row.tVolumn).toFixed(fixedW)+"</td>";
                    }else{
                        rows=rows+"<td>"+Number(row.cVolumn).toFixed(fixedW)+"</td>";
                    }
                    rows=rows+"<td>"+orderStatus[row.orderStatus]+"</td>";
                    rows=rows+"<td>"+row.outroomDt+"</td>";
                });
                $tbody.append(rows);
                var printModule1 = $("#div_loadinfo_detail").html();
                $("#div_loadinfo_detail_print").html('');
                $("#div_loadinfo_detail_print").append(printModule1);
                $("#print_page").show().jqprint();
                $("#print_page").hide();
                $tbody.empty();
            }else{
                $alert(result.message);
            }
        }
    });
}
function inroomGridInit(){
    $("#inroom_order_table").datagrid({
        url:'api/v1/p/mms/loadInfo/inRoomOrderFilter',
        border : false,
        height:$(window).height(),
        pagination : true,
        idField : 'id',
        pageSize : 20,
        pageList : [ 20, 50,  100 ],
        checkOnSelect : true,//单击选中
        selectOnCheck : true,
        rownumbers:true,
        queryParams: {
            logisticsPlanId: 1*selectedLogisticsPlanId
        },
        frozenColumns:[[{
            field : 'orderId',
            checkbox:true
        },{
            field:'orderNo',
            title:'入库单号'
        }]],
        columns:[[
            {
                field:'collectWarehouseName',
                title:'国内仓'
            },{
                field:'toWarehouseName',
                title:'海外仓'
            },{
                field:'logisticsName',
                title:'物流产品'
            },{
                field:'logisticsPlanName',
                title:'物流计划'
            },{
                field:'cNums',
                title:'件数'
            },{
                field:'cWeight',
                title:'毛重(Kg)',
                formatter:function (value,row,index) {
                    if(value==''){
                        return Number(row.tWeight).toFixed(fixedW);
                    }else{
                        return Number(value).toFixed(fixedW);
                    }
                }
            },{
                field:'cVolumn',
                title:'体积(CBM)',
                formatter:function (value,row,index) {
                    if(value==''){
                        return Number(row.tVolumn).toFixed(fixedV);
                    }else{
                        return Number(value).toFixed(fixedV);
                    }
                }
            },{
                field:'orderStatus',
                title:'状态',
                formatter:function (value,row,index) {
                    return orderStatus[value];
                }
            },{
                field:'outroomDt',
                title:'出库时间'
            }
        ]],
        loadFilter:function(data){
            if(data.code!='200'){
                return data.data;
            }
            return data.data;
        },
        onLoadSuccess:function(data){

        }
    })
}
function printInit(){
    $.ajax({
        url:'api/v1/p/mms/loadInfo/load',
        type:'post',
        data:{
            loadInfoId:1*loadInfoId
        },
        dataType:'json',
        success:function (result) {
            if(result.code == 200){
                var $data = result.data;
                selectedLogisticsPlanId = '';
                //重新对dialog填充数据
                printInitLoad($data);
            }else{
                $alert(result.message);
            }
        }
    })
}
function createInit(loadInfoId,logisticsChannelPlanId){
    window.location.href="ship-note-create?loadInfoId="+loadInfoId;
}
function loadInfoLoadReadOnly(loadInfoId) {
    $.ajax({
        url:'api/v1/p/mms/loadInfo/load',
        type:'post',
        data:{
            loadInfoId:1*loadInfoId
        },
        dataType:'json',
        success:function (result) {
            if(result.code == 200){
                var $data = result.data;
                selectedLogisticsPlanId = '';
                //重新对dialog填充数据
                dialogReloadReadOnly($data);
            }else{
                $alert(result.message);
            }
        }
    })
}
function loadInfoLoad(loadInfoId) {
    $.ajax({
        url:'api/v1/p/mms/loadInfo/load',
        type:'post',
        data:{
            loadInfoId:1*loadInfoId
        },
        dataType:'json',
        success:function (result) {
            if(result.code == 200){
                var $data = result.data;
                //将该配载单的物流计划id赋给全局变量
                selectedLogisticsPlanId = $data.logisticsPlanId;
                //重新对dialog填充数据
                dialogReload($data);
            }else{
                $alert(result.message);
            }
        }
    })
}
function printInitLoad($data){
    var $fillText = $('#div_loadinfo_detail_print').find('.fill-text');
    var callback = function (result) {
        if(result.code == 200) {
            var data = result.data.rows;
            var $tbody = $("#load_inroom_order_table_print tbody");
            $tbody.html('');
            var rows='';
            $.each(data,function (index,row) {
                rows=rows+"<tr><td style='display: none;'>"+row.orderId+"</td><td>"+row.orderNo+
                    "</td><td>"+row.collectWarehouseName+"</td><td>"+row.toWarehouseName+"</td><td>"+
                    row.logisticsName+"</td><td>"+row.logisticsPlanName+"</td>";
                if(row.cNums==''||row.cNums==null){
                    rows=rows+"<td>"+row.tNums+"</td>";
                }else{
                    rows=rows+"<td>"+row.cNums+"</td>";
                }
                if(row.cWeight==''||row.cWeight==null){
                    rows=rows+"<td>"+Number(row.tWeight).toFixed(fixedW)+"</td>";
                }else{
                    rows=rows+"<td>"+Number(row.cWeight).toFixed(fixedW)+"</td>";
                }
                if(row.cVolumn==''||row.cVolumn==null){
                    rows=rows+"<td>"+Number(row.tVolumn).toFixed(fixedV)+"</td>";
                }else{
                    rows=rows+"<td>"+Number(row.cVolumn).toFixed(fixedV)+"</td>";
                }
                if(row.orderStatus=='commit'){
                    rows=rows+"<td>"+"已提交"+"</td>"
                }else if(row.orderStatus=='c_collect'){
                    rows=rows+"<td>"+"已揽收"+"</td>"
                }else if(row.orderStatus=='c_receive'){
                    rows=rows+"<td>"+"已收货"+"</td>"
                }else if(row.orderStatus=='c_ourtoom'){
                    rows=rows+"<td>"+"集货出库"+"</td>"
                }else if(row.orderStatus=='p_inroom'){
                    rows=rows+"<td>"+"转运入库"+"</td>"
                }else if(row.orderStatus=='p_outroom'){
                    rows=rows+"<td>"+"转运出库"+"</td>"
                }else if(row.orderStatus=='o_inroom'){
                    rows=rows+"<td>"+"海外入库"+"</td>"
                }else {
                    rows=rows+"<td>"+""+"</td>"
                }
                rows=rows+"<td>"+row.outroomDt+"</td>";
            });
            $tbody.append(rows);
            $("#print_page").show().jqprint();
            $("#print_page").hide();
            $("#div_loadinfo_detail_print .form-group div").html('');
            $tbody.empty();
        }else{
            $alert(result.message);
        }
    };
    loadInfoReload($fillText,$data,callback);
}
function dialogReloadReadOnly($data){
    var $fillText = $('#div_loadinfo_detail_readonly').find('.fill-text');
    var callback = function (result) {
        if(result.code == 200) {
            var data = result.data.rows;
            var $tbody = $("#load_inroom_order_table_readonly tbody");
            $tbody.html('');
            var rows='';
            $.each(data,function (index,row) {
                rows=rows+"<tr><td style='display: none;'>"+row.orderId+"</td><td>"+row.orderNo+
                    "</td><td>"+row.collectWarehouseName+"</td><td>"+row.toWarehouseName+"</td><td>"+
                    row.logisticsName+"</td><td>"+row.logisticsPlanName+"</td>";
                if(row.cNums==''||row.cNums==null){
                    rows=rows+"<td>"+row.tNums+"</td>";
                }else{
                    rows=rows+"<td>"+row.cNums+"</td>";
                }
                if(row.cWeight==''||row.cWeight==null){
                    rows=rows+"<td>"+Number(row.tWeight).toFixed(fixedW)+"</td>";
                }else{
                    rows=rows+"<td>"+Number(row.cWeight).toFixed(fixedW)+"</td>";
                }
                if(row.cVolumn==''||row.cVolumn==null){
                    rows=rows+"<td>"+Number(row.tVolumn).toFixed(fixedV)+"</td>";
                }else{
                    rows=rows+"<td>"+Number(row.cVolumn).toFixed(fixedV)+"</td>";
                }
                if(row.orderStatus=='commit'){
                    rows=rows+"<td>"+"已提交"+"</td>"
                }else if(row.orderStatus=='c_collect'){
                    rows=rows+"<td>"+"已揽收"+"</td>"
                }else if(row.orderStatus=='c_receive'){
                    rows=rows+"<td>"+"已收货"+"</td>"
                }else if(row.orderStatus=='c_ourtoom'){
                    rows=rows+"<td>"+"集货出库"+"</td>"
                }else if(row.orderStatus=='p_inroom'){
                    rows=rows+"<td>"+"转运入库"+"</td>"
                }else if(row.orderStatus=='p_outroom'){
                    rows=rows+"<td>"+"转运出库"+"</td>"
                }else if(row.orderStatus=='o_inroom'){
                    rows=rows+"<td>"+"海外入库"+"</td>"
                }else if(row.orderStatus=='o_shelve'){
                    rows=rows+"<td>"+"海外入库"+"</td>"
                }else {
                    rows=rows+"<td>"+""+"</td>"
                }
                rows=rows+"<td>"+row.outroomDt+"</td>";
            });
            $tbody.append(rows);
            $('#dialog_loadinfo_readonly').modal("show");
        }else{
            $alert(result.message);
        }
    };
    loadInfoReload($fillText,$data,callback);
}
//重新对dialog填充数据
function dialogReload($data){
    var $fillText = $('#div_loadinfo_detail').find('.fill-text');
    var callback = function (result) {
        if(result.code == 200) {
            var data = result.data.rows;
            var $tbody = $("#load_inroom_order_table tbody");
            $tbody.html('');
            var rows='';
            $.each(data,function (index,row) {
                rows=rows+"<tr><td style='display: none;'>"+row.orderId+"</td><td>"+row.orderNo+
                    "</td><td>"+row.collectWarehouseName+"</td><td>"+row.toWarehouseName+"</td><td>"+
                    row.logisticsName+"</td><td>"+row.logisticsPlanName+"</td>";
                if(row.cNums==''||row.cNums==null){
                    rows=rows+"<td>"+row.tNums+"</td>";
                }else{
                    rows=rows+"<td>"+row.cNums+"</td>";
                }
                if(row.cWeight==''||row.cWeight==null){
                    rows=rows+"<td>"+Number(row.tWeight).toFixed(fixedW)+"</td>";
                }else{
                    rows=rows+"<td>"+Number(row.cWeight).toFixed(fixedW)+"</td>";
                }
                if(row.cVolumn==''||row.cVolumn==null){
                    rows=rows+"<td>"+Number(row.tVolumn).toFixed(fixedV)+"</td>";
                }else{
                    rows=rows+"<td>"+Number(row.cVolumn).toFixed(fixedV)+"</td>";
                }
                if(row.orderStatus=='commit'){
                    rows=rows+"<td>"+"已提交"+"</td>"
                }else if(row.orderStatus=='c_collect'){
                    rows=rows+"<td>"+"已揽收"+"</td>"
                }else if(row.orderStatus=='c_receive'){
                    rows=rows+"<td>"+"已收货"+"</td>"
                }else if(row.orderStatus=='c_ourtoom'){
                    rows=rows+"<td>"+"集货出库"+"</td>"
                }else if(row.orderStatus=='p_inroom'){
                    rows=rows+"<td>"+"转运入库"+"</td>"
                }else if(row.orderStatus=='p_outroom'){
                    rows=rows+"<td>"+"转运出库"+"</td>"
                }else if(row.orderStatus=='o_inroom'){
                    rows=rows+"<td>"+"海外入库"+"</td>"
                }else {
                    rows=rows+"<td>"+""+"</td>"
                }
                rows=rows+"<td>"+row.outroomDt+"</td>";
                rows=rows+"<td><a href='#' class='remove'>"+"移除"+"</a></td></tr>"
            });
            $tbody.append(rows);
            $('#dialog_loadinfo').modal("show");
        }else{
            $alert(result.message);
        }
    };
    loadInfoReload($fillText,$data,callback);
}
function loadInfoReload($fillText,$data,callback){
    $fillText.html('');
    $fillText.eq(0).append("<span>"+$data.fromWarehouseName+"</span>");
    $fillText.eq(1).append("<span>"+$data.toWarehouseName+"</span>");
    $fillText.eq(2).append("<span>"+$data.logisticsName+"</span>");
    $fillText.eq(3).append("<span>"+$data.providerCode+"</span>");
    $fillText.eq(4).append("<span>"+$data.logisticsPlanName+"</span>");
    // if($data.logisticsType=='A'){
    //     $fillText.eq(5).append("<span>"+"空运"+"</span>");
    // }else{
    //     $fillText.eq(5).append("<span>"+"海运"+"</span>");
    // }
    $fillText.eq(5).append("<span>"+$data.serviceCategory+"</span>");
    $fillText.eq(6).append("<span>"+$data.startPort+"</span>");
    $fillText.eq(7).append("<span>"+$data.transferPort+"</span>");
    $fillText.eq(8).append("<span>"+$data.destPort+"</span>");
    $fillText.eq(9).append("<span>"+$data.estimateLeaveDt+"</span>");
    $fillText.eq(10).append("<span>"+$data.estimateArriveDt+"</span>");
    $fillText.eq(11).append("<span>"+$data.tBoxNums+"</span>");
    $fillText.eq(12).append("<span>"+Number($data.tWeight).toFixed(fixedW)+"</span>");
    $fillText.eq(13).append("<span>"+Number($data.tVolumn).toFixed(fixedV)+"</span>");
    if($data.state=='N'){
        $fillText.eq(14).append("<span>"+"新建"+"</span>");
    }else{
        $fillText.eq(14).append("<span>"+"已订舱"+"</span>");
    }
    $.ajax({
        url:'api/v1/p/mms/loadInfo/inRoomOrderList',
        type:'post',
        data:{
            loadInfoId:$data.loadInfoId,
            page:1,
            rows:100
        },
        dataType:'json',
        success:callback
    });
}
function removeLoadInroomOrder(orderId,$this) {
    $.ajax({
        url:"api/v1/p/mms/loadInfo/inRoomOrderRemove",
        type:'post',
        data:{
            loadInfoId:1*loadInfoId,
            orderId:1*orderId
        },
        dataType:'json',
        success:function (result) {
            if(result.code == 200) {
                var _num = $this.parent().parent().children().eq(6).text();
                var _weight = $this.parent().parent().children().eq(7).text();
                var _volumn = $this.parent().parent().children().eq(8).text();
                var oldNum = $("#div_loadinfo_detail .form-group:eq(11) div span").text();
                var oldWeight = $("#div_loadinfo_detail .form-group:eq(12) div span").text();
                var oldVolumn = $("#div_loadinfo_detail .form-group:eq(13) div span").text();
                $("#div_loadinfo_detail .form-group:eq(11) div span").text(1*oldNum-_num);
                $("#div_loadinfo_detail .form-group:eq(12) div span").text(Number(1*oldWeight-_weight).toFixed(fixedW));
                $("#div_loadinfo_detail .form-group:eq(13) div span").text(Number(1*oldVolumn-_volumn).toFixed(fixedV));
                $this.parent().parent().remove();
            }else{
                $alert(result.message);
            }
        }
    })
}
function logisticsInit() {
    $("#select_logistics").combobox({
        url:'api/v1/p/mms/logistics/query',
        valueField:'id',
        textField:'name',
        loadFilter:function(result){
            if(result.code=='200'){
                result.data.unshift({id:'',name:'全部'});
                return result.data;
            }
        }
    })
}
function warehouseInit() {
    $("#select_warehouse").combobox({
        url:'api/v1/p/crm/warehouse/query',
        valueField:'warehouseId',
        textField:'warehouseName',
        queryParams:{
            warehouseType:"DEST"
        },
        loadFilter:function(result){
            if(result.code=='200'){
                result.data.unshift({warehouseId:'',warehouseName:'全部'});
                return result.data;
            }
        }
    })
}
function loadInfoGridInit() {
    $("#load_info_table").datagrid({
        url:'api/v1/p/mms/loadInfo/list',
        border : false,
        height:$(window).height(),
        pagination : true,
        idField : 'id',
        pageSize : 20,
        pageList : [ 20, 50,  100 ],
        checkOnSelect : false,//单击选中
        emptyMsg : "暂无数据",
        selectOnCheck : true,
        singleSelect: true,
        rownumbers:true,
        columns:[[
            {
                field:'id',
                hidden: true
            },{
                field:'loadNo',
                title:'配载单号',
                formatter:function (value,row,index) {
                    return "<a href='javascript:;' name='loadNo'>"+value+"</a>"
                }
            },{
                field:'fromWarehouseName',
                title:'国内仓'
            },{
                field:'toWarehouseName',
                title:'海外仓'
            },{
                field:'logisticsChannelPlanName',
                title:'物流计划'
            },{
                field:'startPort',
                title:'起运港'
            },{
                field:'destPort',
                title:'目的港'
            },{
                field:'outroomBoxNums',
                title:'发货包裹数'
            },{
                field:'tNums',
                title:'件数'
            },{
                field:'tWeight',
                title:'毛重(Kg)'
            },{
                field:'tVolumn',
                title:'体积(CBM)'
            },{
                field:'state',
                title:'状态',
                formatter:function (value,row,index) {
                    switch (row.state){
                        case 'N':
                            return '新建';
                        case 'F':
                            return '已订舱';
                        default :
                    }
                }
            },{
                field:'logisticsChannelPlanId',
                title:'物流计划id',
                hidden:true
            },{
                field:'opertation',
                title:'操作',
                hidden:isSale,
                formatter:function (value,row,index) {
                    var t = "";
                    if(row.outroomBoxNums){
                        t = "|<a href='javascript:;' name='create_ship'>生成发货单</a>";
                    }
                    switch (row.state){
                        case 'N':
                            return "<a href='javascript:;' name='modify'>修改</a>|<a href='javascript:;' name='bookStore'>订舱</a>|<a href='javascript:;' name='print'>打印</a>"+t;
                        case 'F':
                            return "<a href='javascript:;' name='print'>打印</a>"+t;
                        default :
                            return "";
                    }
                }

            }
        ]],
        loadFilter:function(data){
            if(data.code == 200){
                return data.data;
            }else{
                return [];
            }
        },
        toolbar:"#tb"
    })
}